package com.applet.mallappletbackstage.handler.exception;

import com.applet.mallappletbackstage.utils.R;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @author X
 * @version 1.0
 * @ClassName GlobalExceptionHandler
 * @description 全局异常处理
 * @date 2020/7/31
 **/
@ControllerAdvice
public class GlobalExceptionHandler {

    /***
     * 全局异常处理器
     * @param e
     * @return
     */
    @ExceptionHandler(Exception.class)
    @ResponseBody
    public R error(Exception e) {
        e.printStackTrace();
        return R.fail(500, "服务器错误", e.getMessage());
    }
}
